Ext.define("App.controller.News", {
	extend: "Ext.app.Controller",
	requires: ["Ext.MessageBox"],
	config: {
		refs: {
			newsCard: "#newsCard",
            newsList: "#newsList",
			newsInfo: "#newsInfo"
        },
		
		control: {
            newsList: {
            	itemtap: "onNewsListItemTap"
            }
		}
	},
	
	
	onNewsListItemTap: function(list, idx, el, record){
		var newsDetailStore = Ext.getStore('NewsDetail');
		var newsId = record.get('newsId');

		newsDetailStore.clearFilter();
		
		newsDetailStore.setProxy({
            type: "jsonp",
            url: "http://www.51inews.com/inewsServer/findExamNewsDetail.action?newsId=" + newsId,
            callbackKey: 'callback',
            reader: {
                type: "json",
                rootProperty: "root"
            }
        });
		newsDetailStore.load();
		if (!this.newsInfo) {
			this.newsInfo = Ext.widget('newsInfo');
		}
		this.newsInfo.config.title = record.get('title');
		this.getNewsCard().push(this.newsInfo);
		this.newsInfo.setStore(newsDetailStore);
	}
	
});